#include<iostream>
#include<stack>
using namespace std;

bool check(char c1,char c2){
    if(c1 == 'f' && c2 == 'c') return true;
    if(c1 == 't' && c2 == 'b') return true;
    return false;
}

int main()
{
    int n;
    cin >> n;
    string str;
    cin>>str;
    stack<char> stk;
    for(int i = 0;i < str.size();i++)
    {
            char c = str[i];
            if(!stk.empty() && check(stk.top(),c)){
                stk.pop();
            }
            else  stk.push(c);
    }
          cout << stk.size() << endl;

    return 0;
}